package com.atguigu.gmall.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.atguigu.gmall.bean.UserAddress;
import com.atguigu.gmall.service.OrderService;
import com.atguigu.gmall.service.UserService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author yhl
 * @create 2021-08-10 10:15
 */
@Service
public class OrderServiceImpl implements OrderService {


    //dubbo直连
    @Reference(loadbalance = "roundrobin", timeout = 1000)
//    @Autowired
    UserService userService;


    @HystrixCommand(fallbackMethod = "hello")
    @Override
    public UserAddress initOrder(String userId) {
        //1、查询用户的收货地址
        UserAddress userAddress = userService.getUserAddressList(userId);

        return userAddress;
    }

    public UserAddress hello(String userId) {
        return new UserAddress(1, "测试", "", "", "", "");
    }
}
